@import "framework/variables";
@import 'framework/tw_bootstrap_variables';
@import "bootstrap/variables";

$active-background: rgba(0, 0, 0, .04);
$active-hover-background: $active-background;
$active-hover-color: $gl-text-color;
$inactive-badge-background: rgba(0, 0, 0, .08);
$hover-background: $white-light;
$hover-color: $gl-text-color;
$inactive-color: $gl-text-color-secondary;
$new-sidebar-width: 220px;
$new-sidebar-collapsed-width: 50px;

.page-with-new-sidebar {
  @media (min-width: $screen-md-min) {
    padding-left: $new-sidebar-collapsed-width;
  }

  @media (min-width: $screen-lg-min) {
    padding-left: $new-sidebar-width;
  }

  // Override position: absolute
  .right-sidebar {
    position: fixed;
    height: calc(100% - #{$new-navbar-height});
  }

  .issues-bulk-update.right-sidebar.right-sidebar-expanded .issuable-sidebar-header {
    padding: 10px 0 15px;
  }
}

.page-with-icon-sidebar {
  @media (min-width: $screen-sm-min) {
    padding-left: $new-sidebar-collapsed-width;
  }
}

.context-header {
  position: relative;
  margin-right: 2px;

  a {
    font-weight: $gl-font-weight-bold;
    display: flex;
    align-items: center;
    padding: 10px 16px 10px 10px;
    color: $gl-text-color;
  }

  &:hover,
  a:hover {
    background-color: $hover-background;
    color: $hover-color;

    .settings-avatar {
      i {
        color: $hover-color;
      }
    }
  }

  .avatar-container {
    flex: 0 0 40px;
    background-color: $white-light;
  }

  .sidebar-context-title {
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.settings-avatar {
  background-color: $white-light;

  i {
    font-size: 20px;
    width: 100%;
    color: $gl-text-color-secondary;
    text-align: center;
    align-self: center;
  }
}

.nav-sidebar {
  position: fixed;
  z-index: 400;
  width: $new-sidebar-width;
  transition: left $sidebar-transition-duration;
  top: $new-navbar-height;
  bottom: 0;
  left: 0;
  background-color: $gray-normal;
  box-shadow: inset -2px 0 0 $border-color;
  transform: translate3d(0, 0, 0);

  &.sidebar-icons-only {
    width: $new-sidebar-collapsed-width;

    .nav-sidebar-inner-scroll {
      overflow-x: hidden;
    }

    .badge:not(.fly-out-badge),
    .sidebar-context-title,
    .nav-item-name {
      display: none;
    }

    .sidebar-top-level-items > li > a {
      min-height: 44px;
    }

    .fly-out-top-item {
      display: block;
    }
  }

  &.nav-sidebar-expanded {
    left: 0;
  }

  a {
    transition: none;
    text-decoration: none;
  }

  ul {
    padding-left: 0;
    list-style: none;
  }

  li {
    white-space: nowrap;

    a {
      display: flex;
      align-items: center;
      padding: 12px 16px;
      color: $inactive-color;
    }

    svg {
      fill: $inactive-color;
    }
  }

  .nav-item-name {
    flex: 1;
  }

  li.active {
    > a {
      font-weight: $gl-font-weight-bold;
    }
  }

  @media (max-width: $screen-xs-max) {
    left: (-$new-sidebar-width);
  }

  .nav-icon-container {
    display: flex;
    margin-right: 8px;

    svg {
      height: 16px;
      width: 16px;
    }
  }

  .fly-out-top-item {
    display: none;
  }
}

.nav-sidebar-inner-scroll {
  height: 100%;
  width: 100%;
  overflow: auto;
}

.with-performance-bar .nav-sidebar {
  top: $new-navbar-height + $performance-bar-height;
}

.sidebar-sub-level-items {
  display: none;
  padding-bottom: 8px;

  > li {
    a {
      padding: 8px 16px 8px 40px;

      &:hover,
      &:focus {
        background: $active-hover-background;
        color: $active-hover-color;
      }
    }

    &.active {
      a {
        &,
        &:hover,
        &:focus {
          background: $active-background;
        }
      }
    }
  }
}

.sidebar-top-level-items {
  margin-bottom: 60px;

  > li {
    > a {
      @media (min-width: $screen-sm-min) {
        margin-right: 2px;
      }

      &:hover {
        color: $gl-text-color;

        svg {
          fill: $gl-text-color;
        }
      }
    }

    &.is-showing-fly-out {
      > a {
        margin-right: 2px;
      }

      .sidebar-sub-level-items {
        @media (min-width: $screen-sm-min) {
          position: fixed;
          top: 0;
          left: $new-sidebar-width;
          min-width: 150px;
          margin-top: -1px;
          padding: 4px 1px;
          background-color: $white-light;
          box-shadow: 2px 1px 3px $dropdown-shadow-color;
          border: 1px solid $gray-darker;
          border-left: 0;
          border-radius: 0 3px 3px 0;

          &::before {
            content: "";
            position: absolute;
            top: -30px;
            bottom: -30px;
            left: -10px;
            right: -30px;
            z-index: -1;
          }

          &.is-above {
            margin-top: 1px;
          }

          .divider {
            height: 1px;
            margin: 4px -1px;
            padding: 0;
            background-color: $dropdown-divider-color;
          }

          > .active {
            box-shadow: none;

            > a {
              background-color: transparent;
            }
          }

          a {
            padding: 8px 16px;
            color: $gl-text-color;

            &:hover,
            &:focus {
              background-color: $gray-darker;
            }
          }
        }
      }
    }

    .badge {
      background-color: $inactive-badge-background;
      color: $inactive-color;
    }

    &.active {
      background: $active-background;

      > a {
        margin-left: 4px;
        padding-left: 12px;
      }

      .badge {
        font-weight: $gl-font-weight-bold;
      }

      .sidebar-sub-level-items:not(.is-fly-out-only) {
        display: block;
      }
    }

    &.active > a:hover,
    &.is-over > a {
      background-color: $white-light;
    }
  }
}


// Collapsed nav

.toggle-sidebar-button,
.close-nav-button {
  width: $new-sidebar-width - 2px;
  position: fixed;
  bottom: 0;
  padding: 16px;
  background-color: $gray-normal;
  border: 0;
  border-top: 2px solid $border-color;
  color: $gl-text-color-secondary;
  display: flex;
  align-items: center;

  i {
    font-size: 20px;
    margin-right: 8px;
  }

  .fa-angle-double-right {
    display: none;
  }

  &:hover {
    background-color: $border-color;
    color: $gl-text-color;
  }
}

.toggle-sidebar-button {
  @media (max-width: $screen-xs-max) {
    display: none;
  }
}


.sidebar-icons-only {
  .context-header {
    height: 61px;

    a {
      padding: 10px 4px;
    }
  }

  li a {
    padding: 12px 15px;
  }

  .sidebar-top-level-items > li {
    &.active a {
      padding-left: 12px;
    }

    .sidebar-sub-level-items {
      @media (min-width: $screen-sm-min) {
        left: $new-sidebar-collapsed-width;
      }

      &:not(.flyout-list) {
        display: none;
      }
    }
  }

  .nav-icon-container {
    margin-right: 0;
  }

  .toggle-sidebar-button {
    width: $new-sidebar-collapsed-width - 2px;
    padding: 16px 18px;

    .collapse-text,
    .fa-angle-double-left {
      display: none;
    }

    .fa-angle-double-right {
      display: block;
    }
  }
}

.fly-out-top-item {
  > a {
    display: flex;
  }

  .fly-out-badge {
    margin-left: 8px;
  }
}

.fly-out-top-item-name {
  flex: 1;
}

// Mobile nav

.close-nav-button {
  display: none;
}

.toggle-mobile-nav {
  display: none;
  background-color: transparent;
  border: 0;
  padding: 6px 16px;
  margin: 0 0 0 -15px;
  height: 46px;

  i {
    font-size: 20px;
    color: $gl-text-color-secondary;
  }

  @media (max-width: $screen-xs-max) {
    display: flex;
    align-items: center;

    i {
      font-size: 18px;
    }
  }
}

@media (max-width: $screen-xs-max) {
  .close-nav-button {
    display: flex;
  }
}

.mobile-overlay {
  display: none;

  &.mobile-nav-open {
    display: block;
    position: fixed;
    background-color: $black-transparent;
    height: 100%;
    width: 100%;
    z-index: 300;
  }
}


// Make issue boards full-height now that sub-nav is gone

.boards-list {
  height: calc(100vh - #{$new-navbar-height});

  @media (min-width: $screen-sm-min) {
    height: 475px; // Needed for PhantomJS
    // scss-lint:disable DuplicateProperty
    height: calc(100vh - 180px);
    // scss-lint:enable DuplicateProperty
  }
}

.with-performance-bar .boards-list {
  height: calc(100vh - #{$new-navbar-height} - #{$performance-bar-height});
}
